﻿// Global namespace
var MasterStroke = MasterStroke || {};

define
(
    ["./Types"],
    function ()
    {
        MasterStroke.Point = function (x, y)
        {
            if (!MasterStroke.Types.isNumber(x))
            {
                throw "x must be an integer";
            }

            if (!MasterStroke.Types.isNumber(y))
            {
                throw "y must be an integer";
            }

            this.getX = function ()
            {
                return x;
            };

            this.getY = function ()
            {
                return y;
            };

            this.distance = function (point)
            {
                if (!(point instanceof MasterStroke.Point))
                {
                    throw "point must be a valid instance of type MasterStroke.Point";
                }

                return Math.sqrt(Math.pow(this.getX() - point.getX(), 2) + Math.pow(this.getY() - point.getY(), 2));
            };

            this.toString = function ()
            {
                return x + "," + y;
            };
        };

        return MasterStroke.Point;
    }
);